package com.tj.view.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/1/23 0023.
 *
 * 刮刮奖自定义view的原理：利用mPaint.setXfermode()方法中的16个模式之一的DstOut方式
 *
 */
public class GuaGuaView extends View {

    private Paint mOutterPaint;
    private Path mPath;//手指路径
    private Canvas mCanvas;
    private Bitmap mBitmap;
    private int mLastX;
    private int mLastY;


    public GuaGuaView(Context context) {
        this(context,null);
    }

    public GuaGuaView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public GuaGuaView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    /**
     * 初始化的一些操作
     */
    private void init(){

        mOutterPaint = new Paint();
        //???
        mPath = new Path();


    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int width = getMeasuredWidth();
        int height = getMeasuredHeight();
        //初始化我们的bitmap
        mBitmap = Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888);
        mCanvas = new Canvas(mBitmap);
        //设置画笔的属性
        mOutterPaint.setColor(Color.RED);
        mOutterPaint.setAntiAlias(true);
        mOutterPaint.setDither(true);//抖动处理
        mOutterPaint.setStrokeJoin(Paint.Join.ROUND);//???
        mOutterPaint.setStrokeCap(Paint.Cap.ROUND);//???
        mOutterPaint.setStyle(Paint.Style.STROKE);//空心笔的样式
        //
        //




    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }




}
